package so.wy.servicecenter.businessbed.extend;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import so.wy.servicecenter.base.frame.manager.AbstractManager;
import so.wy.servicecenter.platformuser.dao.rdb.platform_user.PlatformUserDAO;
import so.wy.servicecenter.platformuser.dao.rdb.platform_user.PlatformUserDO;
import so.wy.servicecenter.platformuser.dao.rdb.platform_user_third.PlatformUserThirdDAO;
import so.wy.servicecenter.platformuser.dao.rdb.platform_user_third.PlatformUserThirdDO;

@Service
@Scope("prototype")
public class UserAppOutManager extends AbstractManager {
    @Autowired
    private PlatformUserThirdDAO userThirdDAO;

    @Autowired
    private PlatformUserDAO platformUserDAO;


    public String getUserOpenId(Long userId) {
        PlatformUserThirdDO userThirdDO = userThirdDAO.selectOne(new LambdaQueryWrapper<PlatformUserThirdDO>()
                .eq(PlatformUserThirdDO::getUserId, userId));

        return userThirdDO == null ? null : userThirdDO.getThirdUserSign();
    }

    public void updateUserPhone(Long userId,String phone){
        PlatformUserDO userDO = new PlatformUserDO();
        userDO.setUserId(userId);
        userDO.setUserPhone(phone);
        platformUserDAO.updateById(userDO);
    }

    public void updateUserNameIcon(Long userId,String name,String icon){
        PlatformUserDO userDO = new PlatformUserDO();
        userDO.setUserId(userId);
        userDO.setUserName(name);
        userDO.setUserIcon(icon);
        platformUserDAO.updateById(userDO);
    }
}
